<?php

namespace app\common\controllers;

use app\components\auth\JwtQueryParamAuth;
use sizeg\jwt\JwtHttpBearerAuth;
use yii\filters\auth\CompositeAuth;

class AccessController extends CorsController {

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return array_merge(parent::behaviors(),[
            'compositeAuth' => [
                'class' => CompositeAuth::className(),
                'user'=>\Yii::$app->getModule($this->module->id)->user,
                'authMethods' => [
                    JwtHttpBearerAuth::className(),
                    JwtQueryParamAuth::className(),
                ],
                'optional'=>$this->optional(),
            ],
        ]);
    }

    public function optional(){
        return [];
    }
}